package views.accounting;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Font;
import javax.swing.JComboBox;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JSeparator;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class PopUpAccounting extends JPanel
{
	private JTextField tfCash;
	private JTextField tfCustomerName;
	private JTextField textField_1;
	private JTextField tfAmountCheque;
	private JRadioButton rdbtnCreditdebitCard;
	private JRadioButton rdbtnCheque;
	private JLabel lblChequeNo;
	private JTextField txtTfchequeno;
	private JLabel lblChequeDate;
	private JTextField tfChequeDate;
	private JLabel lblBank;
	private JButton btnCl;
	private JLabel lblAmount_1;
	private JTextField textField;
	private JTable table;
	private JTextField tfBank;
	private JTextField tfBranch;
	private JButton btnAdd;
	public PopUpAccounting() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		rdbtnCreditdebitCard = new JRadioButton("Credit/Debit Card");
		rdbtnCreditdebitCard.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, rdbtnCreditdebitCard, 20, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, rdbtnCreditdebitCard, 20, SpringLayout.WEST, this);
		add(rdbtnCreditdebitCard);
		
		rdbtnCheque = new JRadioButton("Cheque");
		rdbtnCheque.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, rdbtnCheque, 0, SpringLayout.NORTH, rdbtnCreditdebitCard);
		springLayout.putConstraint(SpringLayout.WEST, rdbtnCheque, 10, SpringLayout.EAST, rdbtnCreditdebitCard);
		add(rdbtnCheque);
		
		JLabel lblCash = new JLabel("Cash");
		lblCash.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCash, 20, SpringLayout.SOUTH, rdbtnCreditdebitCard);
		springLayout.putConstraint(SpringLayout.WEST, lblCash, 20, SpringLayout.WEST, this);
		add(lblCash);
		
		tfCash = new JTextField();
		tfCash.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfCash, 0, SpringLayout.NORTH, lblCash);
		springLayout.putConstraint(SpringLayout.WEST, tfCash, 6, SpringLayout.EAST,lblCash);
		add(tfCash);
		tfCash.setColumns(10);
		
		JLabel lblCustomerName = new JLabel("Customer Name");
		lblCustomerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCustomerName, 20, SpringLayout.SOUTH,lblCash);
		springLayout.putConstraint(SpringLayout.WEST, lblCustomerName, 20, SpringLayout.WEST, this);
		add(lblCustomerName);
		
		tfCustomerName = new JTextField();
		tfCustomerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfCustomerName, 6, SpringLayout.SOUTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, tfCustomerName, 20, SpringLayout.WEST, this);
		add(tfCustomerName);
		tfCustomerName.setColumns(20);
		
		JLabel lblReferenceNo = new JLabel("Reference No");
		lblReferenceNo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblReferenceNo, 0, SpringLayout.NORTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblReferenceNo, 20, SpringLayout.EAST, tfCustomerName);
		add(lblReferenceNo);
		
		textField_1 = new JTextField();
		textField_1.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, textField_1, 0, SpringLayout.NORTH, tfCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, textField_1, 0, SpringLayout.WEST, lblReferenceNo);
		add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblAmount = new JLabel("Amount");
		lblAmount.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblAmount, 0, SpringLayout.NORTH, lblCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblAmount, 20, SpringLayout.EAST, textField_1);
		add(lblAmount);
		
		tfAmountCheque = new JTextField();
		tfAmountCheque.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfAmountCheque, 0, SpringLayout.NORTH, tfCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, tfAmountCheque, 0, SpringLayout.WEST,lblAmount);
		add(tfAmountCheque);
		tfAmountCheque.setColumns(10);
		
		lblChequeNo = new JLabel("Cheque No");
		lblChequeNo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblChequeNo, 20, SpringLayout.SOUTH, tfCustomerName);
		springLayout.putConstraint(SpringLayout.WEST, lblChequeNo, 20, SpringLayout.WEST, this);
		add(lblChequeNo);
		
		txtTfchequeno = new JTextField();
		txtTfchequeno.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, txtTfchequeno, 6, SpringLayout.SOUTH, lblChequeNo);
		springLayout.putConstraint(SpringLayout.WEST, txtTfchequeno, 0, SpringLayout.WEST, rdbtnCreditdebitCard);
		add(txtTfchequeno);
		txtTfchequeno.setColumns(20);
		
		lblChequeDate = new JLabel("Cheque Date");
		lblChequeDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblChequeDate, 0, SpringLayout.NORTH, lblChequeNo);
		springLayout.putConstraint(SpringLayout.WEST, lblChequeDate, 0, SpringLayout.WEST, lblReferenceNo);
		add(lblChequeDate);
		
		tfChequeDate = new JTextField();
		tfChequeDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfChequeDate, 0, SpringLayout.NORTH, txtTfchequeno);
		springLayout.putConstraint(SpringLayout.WEST, tfChequeDate, 0, SpringLayout.WEST, lblReferenceNo);
		add(tfChequeDate);
		tfChequeDate.setColumns(10);
		
		btnCl = new JButton("Cl");
		btnCl.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnCl, 0, SpringLayout.NORTH, tfChequeDate);
		springLayout.putConstraint(SpringLayout.WEST, btnCl, 6, SpringLayout.EAST,tfChequeDate);
		add(btnCl);
		
		lblBank = new JLabel("Bank");
		lblBank.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBank, 0, SpringLayout.NORTH, lblChequeNo);
		springLayout.putConstraint(SpringLayout.WEST, lblBank, 20, SpringLayout.EAST, btnCl);
		add(lblBank);
		
		tfBank = new JTextField();
		tfBank.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		tfBank.setPreferredSize(new Dimension(200, 20));
		springLayout.putConstraint(SpringLayout.NORTH, tfBank, 0, SpringLayout.NORTH, txtTfchequeno);
		springLayout.putConstraint(SpringLayout.WEST, tfBank, 0, SpringLayout.WEST, lblBank);
		add(tfBank);
		
		JLabel lblBranch = new JLabel("Branch");
		lblBranch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBranch, 0, SpringLayout.NORTH, lblChequeNo);
		springLayout.putConstraint(SpringLayout.WEST, lblBranch, 20, SpringLayout.EAST, tfBank);
		add(lblBranch);
		
		tfBranch = new JTextField();
		tfBranch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		tfBranch.setPreferredSize(new Dimension(200, 20));
		springLayout.putConstraint(SpringLayout.NORTH, tfBranch, 0, SpringLayout.NORTH, txtTfchequeno);
		springLayout.putConstraint(SpringLayout.WEST, tfBranch, 0, SpringLayout.WEST, lblBranch);
		add(tfBranch);
		
		lblAmount_1 = new JLabel("Amount");
		lblAmount_1.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblAmount_1, 0, SpringLayout.NORTH, lblChequeNo);
		springLayout.putConstraint(SpringLayout.WEST, lblAmount_1, 178, SpringLayout.EAST, lblBranch);
		add(lblAmount_1);
		
		textField = new JTextField();
		textField.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, textField, 0, SpringLayout.NORTH, txtTfchequeno);
		springLayout.putConstraint(SpringLayout.WEST, textField, 0, SpringLayout.WEST, lblAmount_1);
		add(textField);
		textField.setColumns(10);
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 20, SpringLayout.SOUTH, txtTfchequeno);
		springLayout.putConstraint(SpringLayout.WEST, separator, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, -20, SpringLayout.EAST, this);
		add(separator);
		
		JScrollPane scrollPane = new JScrollPane();
		springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 20, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, scrollPane, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, scrollPane, -20, SpringLayout.EAST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, -20, SpringLayout.SOUTH, this);
		add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Sr.No", "Reference No.", "Cheque No.", "Bank", "Branch", "Cheque Date", "Amount", "Delete"
			}
		));
		table.getColumnModel().getColumn(1).setPreferredWidth(119);
		table.getColumnModel().getColumn(2).setPreferredWidth(104);
		scrollPane.setViewportView(table);
		
		btnAdd = new JButton("add");
		springLayout.putConstraint(SpringLayout.WEST, btnAdd, 133, SpringLayout.EAST, tfCash);
		springLayout.putConstraint(SpringLayout.SOUTH, btnAdd, -33, SpringLayout.NORTH, lblReferenceNo);
		add(btnAdd);
	}
}
